#!/usr/bin/env bash

table_name=topics_raw
table_created=true
raw_data=$HOME/repo/weibo-research/data/raw/topics.csv
table_columns=(\
    "id     varchar(32),"\
    "link   varchar(500),"\
    "reads  bigint,"\
    "name   varchar(500),"\
    "timestamp  varchar(10)"\
)
if ! $table_created ; then
    psql dev_database <<__EOF
        create table ${table_name} (${table_columns[@]});
__EOF
fi
# Import data
psql dev_database <<__EOF
    \\copy $table_name from '$raw_data' delimiter ',' CSV HEADER;
__EOF



